package gw.com.android.ui.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.support.annotation.NonNull;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;

import com.gwtsz.gts2.hx.R;

import gw.com.android.app.ActivityManager;
import gw.com.android.app.AppMain;
import gw.com.android.model.ConfigType;
import gw.com.android.model.ConfigUtil;
import www.com.library.model.DataItemDetail;

/**
 * 平仓盈利后，分享成功，显示该弹窗
 *
 * @author jett
 * @since 2017-09-08.
 */
public class ProfitShareDialog extends Dialog {

    private Activity mActivity;

    public ProfitShareDialog(@NonNull Activity context) {
        super(context, R.style.dialog_loading_bar_no_frame);
        this.mActivity = context;
        init();
    }

    private void init() {
        setCancelable(true);
        setCanceledOnTouchOutside(true);

        View root = View.inflate(getContext(), R.layout.dialog_profit_share, null);
        root.findViewById(R.id.iv_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        root.findViewById(R.id.btn_lottery).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String mUrl = ConfigUtil.instance().getUrlPath(ConfigType.LOTTERY_PROFIT_SHARE_TAG);
                DataItemDetail item = new DataItemDetail();
                item.setStringValue(ConfigType.CONFIG_TYPE_TYPE_URL_TAG, mUrl);
                ActivityManager.showWebPageActivity(mActivity, item, AppMain.getAppString(R.string.btn_back));
                dismiss();
            }
        });
        DisplayMetrics dm = mActivity.getResources().getDisplayMetrics();
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams((int) (dm.widthPixels * 0.85), ViewGroup.LayoutParams.WRAP_CONTENT);
        setContentView(root, lp);
    }

}
